package com.zzcoder.mall.common.dto;

import com.zzcoder.mall.data.model.PmsProduct;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "商品（带分类）")
@Data
public class PmsProductWithCategory extends PmsProduct {
    @ApiModelProperty(value = "分类路径")
    private List<String> categoryPath = new ArrayList<>();

    @ApiModelProperty(value = "分类树节点")
    private PmsCategoryTreeNode categoryTree;

    public PmsProductWithCategory() {
    }

    public PmsProductWithCategory(PmsProduct p) {
        if (p == null) {
            return;
        }
        this.setId(p.getId());
        this.setCreatedTime(p.getCreatedTime());
        this.setCreatorId(p.getCreatorId());
        this.setLastModifiedTime(p.getLastModifiedTime());
        this.setLastModifierId(p.getLastModifierId());
        this.setName(p.getName());
        this.setSummary(p.getSummary());
        this.setDetail(p.getDetail());
        this.setImgUrl(p.getImgUrl());
        this.setStock(p.getStock());
        this.setPrice(p.getPrice());
        this.setSellingStatus(p.getSellingStatus());
        this.setCategoryId(p.getCategoryId());
    }
}
